package com.innovation.chengzhangriji.ui.widget;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.innovation.chengzhangriji.ui.BaseLoginFragment;
import com.innovation.chengzhangriji.ui.LoginDynamicFragment;
import com.innovation.chengzhangriji.ui.LoginNormalFragment;

public class LoginPagerAdapter extends FragmentPagerAdapter {

    private static final int FRAGMENT_COUNT = 2;

    private BaseLoginFragment.LoginSuccessListener mListener;

    public LoginPagerAdapter(FragmentManager fm,BaseLoginFragment.LoginSuccessListener listener) {
        super(fm);
        mListener = listener;
    }

    @Override
    public Fragment getItem(int position) {
        BaseLoginFragment fragment = null;
        switch (position) {
            case 0:
                fragment = new LoginNormalFragment();
                fragment.setLoginSuccessListener(mListener);
                break;
            case 1:
                fragment = new LoginDynamicFragment();
                fragment.setLoginSuccessListener(mListener);
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return FRAGMENT_COUNT;
    }
}
